package com.zsk.shop.controller.gop;

import com.zsk.shop.common.annotion.NoPermission;
import com.zsk.shop.common.base.BaseResponse;
import com.zsk.shop.common.base.page.BasePageParams;
import com.zsk.shop.common.utils.ToolUtil;
import com.zsk.shop.entity.ShopGoodsLabel;
import com.zsk.shop.model.params.ShopGoodsLabelAddParams;
import com.zsk.shop.model.params.ShopGoodsLabelEditParams;
import com.zsk.shop.service.ShopGoodsLabelService;
import com.zsk.shop.service.ShopGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ljh
 * @create 2021/11/25 14:27
 */
@RestController
@Api(tags = "GOP商品标签相关")
@RequestMapping("/gop/goodsLabel")
public class GopGoodsLabelController {
    @Resource
    private ShopGoodsLabelService shopGoodsLabelService;

    @Resource
    private ShopGoodsService shopGoodsService;

    @NoPermission
    @ApiOperation(value = "标签【新增】")
    @PostMapping("/addGoodsCategory.do")
    public BaseResponse addGoodsLabel(@RequestBody ShopGoodsLabelAddParams params) {
        return shopGoodsLabelService.addGoodsLabel(params);
    }

    @NoPermission
    @ApiOperation(value = "标签【列表】")
    @PostMapping("/gopGoodsLabelList.do")
    public BaseResponse<List<ShopGoodsLabel>> gopGoodsLabelList(@RequestBody BasePageParams params) {
        return shopGoodsLabelService.gopGoodsLabelList(params);
    }

    @NoPermission
    @ApiOperation(value = "标签【编辑】")
    @PostMapping("/editGoodsCategory.do")
    public BaseResponse editGoodsLabel(@RequestBody ShopGoodsLabelEditParams params) {
        if (ToolUtil.isOneEmpty(params, params.getId(), params.getLabelName())) {
            return BaseResponse.error("必填参数缺失。");
        }
        return shopGoodsLabelService.editGoodsLabel(params);
    }

    @NoPermission
    @ApiOperation(value = "标签【禁启用】")
    @GetMapping("/reviewGoodsLabel.do")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "类表中分类id", dataType = "Long", required = true),
            @ApiImplicitParam(name = "letDisable", value = "true变成禁用状态,false变成启用状态", dataType = "Boolean", required = true)
    })
    public BaseResponse reviewGoodsLabel(Long id, Boolean letDisable) {
        return shopGoodsLabelService.reviewGoodsLabel(id, letDisable);
    }

    @NoPermission
    @ApiOperation(value = "标签【删除】")
    @GetMapping("/deleteGoodsLabel.do")
    @ApiImplicitParam(name = "id", value = "类表中分类id", dataType = "Long", required = true)
    public BaseResponse deleteGoodsLabel(Long id) {
        return shopGoodsLabelService.deleteGoodsLabel(id);
    }


}
